package com.mstanford.movie.controller;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.mstanford.movie.dao.MovieDao;
import com.mstanford.movie.utils.DataUtil;

public class MemberPhotoServlet extends HttpServlet  {

	private static final long serialVersionUID = 1L;
	protected void service(HttpServletRequest req,HttpServletResponse res) throws ServletException,IOException{
		res.setCharacterEncoding("utf-8");
		
		String memberId = req.getParameter("id");
		MovieDao dao = new MovieDao();
		Map<String, String> map = new HashMap<String, String>();
		map= dao.queryMemberPhoto(memberId);
		map.remove("memberPwd");
		String json = DataUtil.mapToJson(map);
		if(map.get("adressPhoto")==null){
			map.put("adressPhoto", "img/web/timg.jpg");
		}
		req.setAttribute("adressPhoto", map.get("adressPhoto"));
		req.setAttribute("json", json);
		req.getRequestDispatcher("memberCenter.jsp").forward(req, res);
	}
}
